﻿#define _CRT_SECURE_NO_WARNINGS 1

#include "system.h"

int main() 
{
	char ch;
	read_file();
	menu();//菜单
	do 
	{
		printf("请选择:");
		ch = getchar();
		fflush(stdin);                       //刷新缓存区
		switch (ch) 
		{
		case '1':
			addNode();                       //添加教师信息
			break;
		case '2':
			deleteNodeByIdOrName();          //删除教师信息
			break;
		case '3':
			editNodeByIdOrName();            //修改教师信息
			break;
		case '4':
			searchNodeByNameOrIdOrAll();     //查询教师信息
			break;
		case '0':
			exit(0);                         //退出查询
		}
	} while (ch != '0');
}



void read_file() 
{
	file = fopen(FILENAME, "r+");//打开文件以读写的形式r+（以读写的形式打开文件的时候如果文件不存在则打开失败）
	if (file == NULL) //打开失败
	{
		file = fopen(FILENAME, "w");//写
		if (file == NULL)
			printf("\n\t文件创建失败!");
	}
	else //打开文件
	{

		int k, len = 0, c = 0;
		while ((k = fgetc(file)) != EOF) //字符输入函数
		{
			if (k == '\n') 
			{
				if (c != 1)
					len++;
			}
			c++;
		}

		int id;
		char name[20];
		char sex[5];
		char workPlace[100];
		char address[100];
		char tel[20];
		float salary;
		float benefit;
		float livingAllowance;
		float shouldPay;
		float waterBill;
		float incomeTax;
		float fund;
		float  totalDeduct;
		float realPay;
		teacher* p = (teacher*)malloc(sizeof(teacher));
		rewind(file); //让⽂件指针的位置回到⽂件的起始位置
		int i;
		for (i = 0; i < len; i++) {
			fscanf(file, "%d%s%s%s%s%s%f%f%f%f%f%f%f%f%f",//输入
				&id, name, sex, workPlace, address, tel, &salary, &benefit, &livingAllowance,
				&shouldPay, &waterBill, &incomeTax, &fund, &totalDeduct, &realPay);
			teacher* pn = (teacher*)malloc(sizeof(teacher));
			pn->id = id;
			strcpy(pn->name, name);
			strcpy(pn->sex, sex);
			strcpy(pn->workPlace, workPlace);
			strcpy(pn->address, address);
			strcpy(pn->tel, tel);
			pn->salary = salary;
			pn->benefit = benefit;
			pn->livingAllowance = livingAllowance;
			pn->shouldPay = shouldPay;
			pn->waterBill = waterBill;
			pn->incomeTax = incomeTax;
			pn->fund = fund;
			pn->totalDeduct = totalDeduct;
			pn->realPay = realPay;
			pn->pnext = NULL;
			p->pnext = pn;
			p = pn;

			if (pHead == NULL)
			{
				pHead = p;
			}

		}

	}
	fclose(file);//关闭文件
}




void menu()              //菜单
{
	system("cls");       //打印菜单前清屏
	printf("***************教师工资管理系统***************\n");
	printf("-------------------菜单列表-------------------\n");
	printf("*               1:添加教师信息               *\n");
	printf("*               2.删除教师信息               *\n");
	printf("*               3:修改教师信息               *\n");
	printf("*               4:查询教师信息               *\n");
	printf("*               0.退出程序                   *\n");
	printf("**********************************************\n");
}










int check_number(int id) //防止添加信息时教师号重复
{
	teacher* p;
	if (pHead == NULL)
	{
		return 0;
	}
	else 
	{
		p = pHead;
		while (p->id != id)
		{
			p = p->pnext;
			if (p == NULL)
				return 0;
		}
		printf("教师号已存在！\n");
		return 1;
	}
}



int check_sex(char* s) //性别只有男女
{
	if (strcmp(s, "男") == 0 || strcmp(s, "女") == 0) //strcmp函数比较
	{
		return 0;
	}
	else 
	{
		printf("性别不合法!\n");
		return 1;
	}
}





void showNode(teacher* node)//显示该教师的信息
{

	printf("教师号:%d\n姓名：%s\n性别：%s\n单位名称：%s\n家庭住址：%s\n联系电话：%s\n基本工资:%.2f\n津贴:    %.2f\n生活补贴:%.2f\n应发工资:%.2f\n水电费:  %.2f\n所得税:  %.2f\n公积金:  %.2f\n合计扣款:%.2f\n实发工资:%.2f\n",
		node->id, node->name, node->sex, node->workPlace, node->address, node->tel, node->salary, node->benefit,
		node->livingAllowance, node->shouldPay, node->waterBill, node->incomeTax, node->fund, node->totalDeduct, node->realPay);

}


teacher* findLinkById() //查询符合条件的教师信息链表中的教师信息节点
{
	int id;
	printf("请输入教师号:");
	scanf("%d", &id);
	if (pHead == NULL) 
	{
		return NULL;
	}
	else 
	{
		teacher* p = pHead;
		while (id != p->id)
		{
			p = p->pnext;
			if (p == NULL) //将指针置于NULL防止野指针
			{
				return NULL;
			}
		}
		return p;
	}
}





void deleteNode(teacher* node)//在界面上输出该节点并询问是否删除
{
	char ch;
	printf("------------下面是要删除的教师信息------------\n");
	showNode(node);//输出该节点中的教师信息
	printf("----------------------------------------------\n");
	printf("是否删除该信息(y/n)\n");
	do
	{
		ch = getch();
		if (ch == 'n')                                  //取消
		{
			printf("取消成功！\n");
			printf("--------按任意键回到菜单---------\n");
			getch();
			deleteNodeByIdOrName();
			return;//return: 从当前的方法中退出,返回到该调用的方法的语句处,继续执行。
		}
		else if (ch == 'y')                            //确定，删除查询到的链表，并将删除后更新的链表存放进文件
		{
			if (node->id == pHead->id)
			{
				pHead = pHead->pnext;
				free(node);
			}
			else if (node->pnext == NULL)
			{
				teacher* k;
				k = pHead;
				while (k->pnext != node)
				{
					k = k->pnext;
				}
				k->pnext = NULL;
			}
			else
			{
				teacher* d = pHead;
				while (d->pnext != node)
				{
					d = d->pnext;
				}
				d->pnext = node->pnext;
			}
			link_save();//保存新节点
			printf("---------删除成功!---------------\n");
			printf("--------按任意键回到菜单---------\n");
			getch();
			deleteNodeByIdOrName();
			return;
		}
		else                                         //输出再次询问
		{
			printf("是否删除该信息(输入y/n)\n");
		}

	} while (ch != 'n' || ch != 'y');//如果输入错误不是y或n则循环让用户选择
}




void link_save() //再将更新的链表存放进文件
{

	teacher* p = pHead;
	if ((file = fopen(FILENAME, "w")) == NULL) 
	{
		printf("文件创建失败!\n");
		exit(1);
	}
	while (p != NULL)
	{
		fprintf(file, "%d %s %s %s %s %s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n",
			p->id, p->name, p->sex, p->workPlace, p->address, p->tel, p->salary, p->benefit,
			p->livingAllowance, p->shouldPay, p->waterBill,p->incomeTax, p->fund, p->totalDeduct, p->realPay);
			p = p->pnext;
	}
	fclose(file);
}





teacher* findNodesByName(char* name, teacher* lista)//查询符合条件的教师信息链表中的教师信息节点
{

	teacher* listb;
	if (lista == NULL) return NULL;
	while (lista != NULL)
	{
		if (strcmp(name, lista->name) != 0) 
		{
			lista = lista->pnext;
		}
		else 
		{
			listb = (teacher*)malloc(sizeof(teacher));
			listb->id = lista->id;
			strcpy(listb->name, lista->name);
			strcpy(listb->sex, lista->sex);
			strcpy(listb->workPlace, lista->workPlace);
			strcpy(listb->address, lista->address);
			strcpy(listb->tel, lista->tel);
			listb->salary = lista->salary;
			listb->benefit = lista->benefit;
			listb->livingAllowance = lista->livingAllowance;
			listb->shouldPay = lista->shouldPay;
			listb->waterBill = lista->waterBill;
			listb->incomeTax = lista->incomeTax;
			listb->fund = lista->fund;
			listb->totalDeduct = lista->totalDeduct;
			listb->realPay = lista->realPay;
			listb->pnext = findNodesByName(name, lista->pnext);
			return listb;
		}
	}
}




int link_length(teacher* head) 
{
	int length = 0;
	teacher* n = head;
	while (NULL != n) 
	{
		length++;
		n = n->pnext;
	}
	return length;
}




void showLink(teacher* head) //按列输出
{
	teacher* p = head;
	while (p != NULL) 
	{
		printf("教师号:%d\n姓名：%s\n性别：%s\n单位名称：%s\n家庭住址：%s\n联系电话：%s\n基本工资:%.2f\n津贴:%.2f\n生活补贴:%.2f\n应发工资:%.2f\n电话费:%.2f\n水电费:%.2f\n房租:%.2f\n所得税:%.2f\n卫生费:%.2f\n公积金:%.2f\n合计扣款:%.2f\n实发工资:%.2f\n",
			p->id, p->name, p->sex, p->workPlace, p->address, p->tel, p->salary, p->benefit,
			p->livingAllowance, p->shouldPay, p->waterBill,p->incomeTax , p->fund, p->totalDeduct, p->realPay);

			p = p->pnext;
	}
}






void showLinkByRowOrCol(teacher* head) //选择按行输出或者按列输出
{
	char ch;
	printf("请选择按行输出(1)or按列输出(2)：\n");
	getchar();
	ch = getchar();
	fflush(stdin);
	switch (ch) 
	{
	case '1':
		showLinkByRow(head);//按行输出
		break;
	case '2':
		showLink(head);//按列输出
		break;
	case '0':
		exit(0);
	}

}





void editNode(teacher* node) //是否修改信息及确认修改信息后重新输入教师信息
{
	char ch;
	printf("------------以下是要修改的教师信息------------\n");
	showNode(node);//显示该教师信息
	printf("----------------------------------------------\n");
	printf("是否修改该信息(y/n)\n");
	do 
	{
		ch = getch();
		if (ch == 'n') //取消
		{
			printf("取消成功！\n");
			printf("--------按任意键回到菜单---------\n");
			getch();
			editNodeByIdOrName();
			return;//返回执行该函数处
		}
		else if (ch == 'y') //确认修改
		{
			printf("请重新输入以下信息:\n");
			printf("==========================================\n");
			printf("请输入教师姓名:");
			scanf("%s", &node->name);
			printf("请输入教师性别:");
			scanf("%s", &node->sex);
			printf("请输入教师单位名称:");
			scanf("%s", &node->workPlace);
			printf("请输入教师家庭住址:");
			scanf("%s", &node->address);
			printf("请输入教师的电话号码:");
			scanf("%s", &node->tel);
			printf("==========================================\n");
			printf("请输入教师基本工资:");
			scanf("%f", &node->salary);
			printf("请输入教师的津贴:");
			scanf("%f", &node->benefit);
			printf("请输入教师的生活补贴:");
			scanf("%f", &node->livingAllowance);
			node->shouldPay = node->salary + node->benefit + node->livingAllowance;
			printf("==========应发工资为：%.2f=============\n", node->shouldPay);
			printf("请输入教师的水电费:");
			scanf("%f", &node->waterBill);
			printf("请输入教师的所得税:");
			scanf("%f", &node->incomeTax);
			printf("请输入教师的公积金:");
			scanf("%f", &node->fund);
			node->totalDeduct = node->waterBill + node->incomeTax + node->fund;
			printf("==========合计扣款为：%.2f=============\n", node->totalDeduct);
			node->realPay = node->shouldPay - node->totalDeduct;
			printf("==========实发工资为：%.2f=============\n", node->realPay);
			printf("==========================================\n");

			link_save();
			printf("---------修改成功!---------------\n");
			printf("--------按任意键回到菜单---------\n");
			getch();
			editNodeByIdOrName();
			return;//修改成功后返回函数引用处
		}
		else 
		{
			printf("是否修改该信息(y/n)\n");
		}

	} while (ch != 'n' || ch != 'y');//如果输入的不是y/n则循环，重新输入
}







void showLinkByRow(teacher* head) {
	teacher* t = head;
	teacher* p = head;
	int i;
	for (i = 0; i < 100; i++)printf("-");
	printf("\n");
	printf("教师号\t姓名\t性别\t单位\t家庭住址\t电话号\n");
	while (t != NULL) {
		printf("%d\t%-6s\t%2s\t%4s\t%4s\t\t%11s\t\n",
			t->id, t->name, t->sex, t->workPlace, t->address, t->tel);
		t = t->pnext;
	}

	for (i = 0; i < 100; i++)printf("-");
	printf("\n");
	printf("教师号\t姓名\t基本工资 津贴   生活补贴 电话费  水电费\t房租  所得税  卫生费  公积金  应付工资  合计扣款  实付工资\n");
	while (p != NULL) {
		printf("%-8d%-8s%-9.1f%-7.1f%-9.1f%-8.1f%-6.1f%-8.1f%-10.1f%-10.1f%-.1f\n",
			p->id, p->name, p->salary, p->benefit,
			p->livingAllowance, p->shouldPay,  p->waterBill,
			 p->incomeTax,  p->fund, p->totalDeduct, p->realPay);

		p = p->pnext;
	}
	for (i = 0; i < 100; i++)printf("-");
	printf("\n");
}




teacher* findLinkByName(char* name) //通过名字找节点
{
	if (pHead == NULL) 
	{
		return NULL;
	}
	else
	{
		teacher* p = pHead;
		while ((strcmp(name, p->name)) != 0) 
		{
			p = p->pnext;
			if (p == NULL) 
			{
				return NULL;
			}
		}
		return p;

	}
}











teacher* merge(teacher* list1, teacher* list2) 
{
	teacher* newList = (teacher*)malloc(sizeof(teacher));
	teacher* nHead = newList;
	teacher* nTail = newList;
	newList->realPay = 0;
	newList->pnext = NULL;
	teacher* p = list1;
	teacher* q = list2;
	while (p != NULL && q != NULL) 
	{
		if (p->realPay <= q->realPay)
		{
			nTail->pnext = p;
			nTail = p;
			p = p->pnext;
		}
		else 
		{
			nTail->pnext = q;
			nTail = q;
			q = q->pnext;
		}
	}
	if (p != NULL) nTail->pnext = p;
	if (q != NULL) nTail->pnext = q;
	return nHead->pnext;
}





teacher* sortList(teacher* head) 
{
	if (head == NULL) return head;
	if (head->pnext == NULL) return head;
	teacher* slow = head;
	teacher* fast = head;
	teacher* pre = NULL;
	while (fast->pnext != NULL && fast->pnext->pnext != NULL) 
	{
		pre = slow;
		slow = slow->pnext;
		fast = fast->pnext->pnext;
	}
	if (fast->pnext != NULL) 
	{
		pre = slow;
		slow = slow->pnext;
	}
	teacher* mid = slow;
	pre->pnext = NULL;
	teacher* L1 = sortList(head);
	teacher* L2 = sortList(mid);
	return merge(L1, L2);
}





teacher* copyLink(teacher* lista) 
{
	teacher* listb;
	if (lista == NULL)
	{
		return NULL;
	}
	else 
	{
		listb = (teacher*)malloc(sizeof(teacher));
		listb->id = lista->id;
		strcpy(listb->name, lista->name);
		strcpy(listb->sex, lista->sex);
		strcpy(listb->workPlace, lista->workPlace);
		strcpy(listb->address, lista->address);
		strcpy(listb->tel, lista->tel);
		listb->salary = lista->salary;
		listb->benefit = lista->benefit;
		listb->livingAllowance = lista->livingAllowance;
		listb->shouldPay = lista->shouldPay;
		listb->waterBill = lista->waterBill;
		listb->incomeTax = lista->incomeTax;
		listb->fund = lista->fund;
		listb->totalDeduct = lista->totalDeduct;
		listb->realPay = lista->realPay;
		listb->pnext = copyLink(lista->pnext);
		return listb;
	}
}



void addNode() //添加教师信息
{
	system("cls");
	teacher* pnew;
	char ch;
	pnew = (teacher*)malloc(sizeof(teacher));
	printf("请输入教师的信息:\n");
	printf("==========================================\n");
	do 
	{
		printf("请输入教师号:");
		scanf("%d", &pnew->id);
	} while (check_number(pnew->id));

	printf("请输入教师姓名:");
	scanf("%s", &pnew->name);
	do 
	{
		printf("请输入教师性别:");
		scanf("%s", &pnew->sex);
	} while (check_sex(pnew->sex));

	printf("请输入教师单位名称:");
	scanf("%s", &pnew->workPlace);
	printf("请输入教师家庭住址:");
	scanf("%s", &pnew->address);
	printf("请输入教师电话:");
	scanf("%s", &pnew->tel);
	printf("==========================================\n");
	printf("请输入教师基本工资:");
	scanf("%f", &pnew->salary);
	printf("请输入教师的津贴:");
	scanf("%f", &pnew->benefit);
	printf("请输入教师的生活补贴:");
	scanf("%f", &pnew->livingAllowance);
	pnew->shouldPay = pnew->salary + pnew->benefit + pnew->livingAllowance;
	printf("==========应发工资为：%.2f=============\n", pnew->shouldPay);
	printf("请输入教师的水电费:");
	scanf("%f", &pnew->waterBill);
	printf("请输入教师的所得税:");
	scanf("%f", &pnew->incomeTax);
	printf("请输入教师的公积金:");
	scanf("%f", &pnew->fund);
	pnew->totalDeduct =  pnew->waterBill + pnew->incomeTax + pnew->fund;
	printf("==========合计扣款为：%.2f=============\n", pnew->totalDeduct);
	pnew->realPay = pnew->shouldPay - pnew->totalDeduct;
	printf("==========实发工资为：%.2f=============\n", pnew->realPay);
	printf("==========================================\n");
	showNode(pnew);
	printf("==========================================\n");
	printf("是否录入该教师的信息(输入y/n)\n");
	do 
	{
		ch = getch();                         //y\n
		if (ch == 'n')
		{
			printf("取消成功！\n");
			printf("\n-------按任意键回到主菜单--------");//回到菜单前清屏
			getch();
			menu();
			return;
		}
		else if (ch == 'y') 
		{
			if (pHead == NULL)
			{
				pHead = pnew;
				pHead->pnext = NULL;
				printf("录入成功!\n");
				link_save();                               //保存
				printf("按任意键回到主菜单");
				getch();
				menu();
				return;
			}
			if (pHead->id > pnew->id) 
			{
				teacher* pr = pHead;
				pHead = pnew;
				pHead->pnext = pr;
			}
			else 
			{
				teacher* p;
				teacher* bf = NULL;
				p = pHead;
				while (p->id < pnew->id)
				{
					bf = p;
					p = p->pnext;
					if (p == NULL) 
					{
						bf->pnext = pnew;
						pnew->pnext = NULL;
						printf("录入成功!\n");
						link_save();
						printf("\n-------按任意键回到主菜单--------");
						getch();
						getchar();
						menu();
						return; //return: 从当前的方法中退出, 返回到该调用的方法的语句处, 继续执行。
					}
				}
				pnew->pnext = p;
				bf->pnext = pnew;
			}
			printf("录入成功!\n");
			link_save();
			printf("\n-------按任意键回到主菜单--------");
			getch();
			getchar();
			menu();
		}
		else 
		{
			printf("是否录入该教师的信息(输入y/n)\n");
		}

	} while (ch != 'n' || ch != 'y');//do while如果不是输入y\n则循环重新输入
}




void deleteNodeByIdOrName() //删除教师信息
{
	system("cls");
	char ch;
	printf("***************教师工资管理系统***************\n");
	printf("-----------------删除教师信息-----------------\n");
	printf("*              1.根据教师号删除              *\n");
	printf("*              2.根据教师姓名删除            *\n");
	printf("*              3.回到主菜单                  *\n");
	printf("*              0.退出程序                    *\n");
	printf("**********************************************\n");
	do 
	{
		printf("请选择:");
		ch = getchar();
		fflush(stdin);
		switch (ch) //选择按名字还是教师号删除
		{
			teacher* find;//结构体指针
			teacher* nodes;
			char name[20];
		case '1':
			find = findLinkById();//查询符合条件的教师信息链表中的教师信息节点
			if (find != NULL) 
			{
				deleteNode(find);//询问是否删除
			}
			else //==NULL
			{
				printf("系统中没有找到此教师\n");
				printf("--------按任意键回到菜单---------\n");
				getch();
				deleteNodeByIdOrName();
			}
			break;
		case '2':
			printf("请输入教师姓名:");
			scanf("%s", &name);//输入要删除教师信息的教师姓名
			nodes = findNodesByName(name, copyLink(pHead));//查找符合条件的教师信息链表中的信息节点
			if (link_length(nodes) == 1) //没有重名则用教师名删除
			{
				find = findLinkByName(nodes->name);
				deleteNode(find);//询问是否确认删除
				break;
			}
			else if (link_length(nodes) > 1)//有重名则改用教师号删除
			{
				printf("有教师重名，删除失败！\n");
				printf("==========================================\n");
				printf("\n提示：请根据教师号删除\n\n");
				printf("--------按任意键回到菜单---------\n");
				getch();
				deleteNodeByIdOrName();//重新选择教师号删除
				break;
				break;
			}
			else 
			{
				printf("系统中没有找到此教师\n");
				printf("--------按任意键回到菜单---------\n");
				getch();
				deleteNodeByIdOrName();//重新选择教师号还是教师名字删除
				break;
			}
		case '3':
			menu();
			break;
		case '0':
			exit(0);//正常退出程序
			break;
		}
	} while (ch != '0');
}




void editNodeByIdOrName()//修改教师信息
{
	system("cls");
	char ch;
	getchar();
	printf("***************教师工资管理系统***************\n");
	printf("----------------修改教师信息-----------------\n");
	printf("*              1.根据教师号修改              *\n");
	printf("*              2.根据教师姓名修改            *\n");
	printf("*              3.回到主菜单                  *\n");
	printf("*              0.退出程序                    *\n");
	printf("**********************************************\n");
	do 
	{
		printf("请选择:");
		ch = getchar();//选择是根据教师号还是教师名字修改教师信息
		fflush(stdin);//清空缓冲区
		switch (ch) 
		{
			teacher* find;
			teacher* nodes;
			char name[20];
		case '1':
			find = findLinkById();//查询符合条件的教师信息链表中的教师信息节点
			if (find != NULL) 
			{
				editNode(find);
			}
			else 
			{
				printf("系统中没有找到此教师\n");
				printf("--------按任意键回到菜单---------\n");
				getch();
				editNodeByIdOrName();
			}
			break;
		case '2':
			printf("请输入教师姓名:");
			scanf("%s", &name);
			nodes = findNodesByName(name, copyLink(pHead));
			if (link_length(nodes) == 1) 
			{
				find = findLinkByName(nodes->name);
				editNode(find);
				break;
			}
			else if (link_length(nodes) > 1)
			{
				printf("有教师重名，修改失败！\n重名结果如下：\n");
				printf("==========================================\n");
				printf("==========================================\n");
				printf("\n提示：请根据教师号修改\n\n");
				printf("--------按任意键回到菜单---------\n");
				getch();
				editNodeByIdOrName();
				break;
			}
			else
			{
				printf("系统中没有找到此教师\n");
				printf("--------按任意键回到菜单---------\n");
				getch();
				editNodeByIdOrName();
				break;
			}
		case '3':
			menu();
			break;
		case '0':
			exit(0);
			break;
		}
	} while (ch != '0');
}



void searchNodeByNameOrIdOrAll() //查找教师信息
{
	system("cls");
	char ch;
	printf("***************教师工资管理系统***************\n");
	printf("-----------------查询教师信息-----------------\n");
	printf("*              1.根据教师号查询              *\n");
	printf("*              2.根据教师姓名查询            *\n");
	printf("*              3.按教师号显示教师信息        *\n");
	printf("*              4.按工资(低->高)显示教师信息  *\n");
	printf("*              5.回到主菜单                  *\n");
	printf("*              0.退出程序                    *\n");
	printf("**********************************************\n");
	do 
	{
		printf("请选择:");
		ch = getchar();
		fflush(stdin);
		switch (ch)
		{
			teacher* find;
			char name[20];
		case '1'://教师号查询
			find = findLinkById();
			if (find != NULL) 
			{
				printf("==========================================\n");
				showNode(find);
				printf("==========================================\n");
			}
			else 
			{
				printf("系统中没有找到此教师\n");
			}
			printf("--------按任意键回到菜单---------\n");
			getch();
			searchNodeByNameOrIdOrAll();
			break;
		case '2'://教师名字查询
			printf("请输入教师姓名:");
			scanf("%s", &name);
			find = findNodesByName(name, copyLink(pHead));
			if (find != NULL) 
			{
				printf("==========================================\n");
				if (link_length(find) == 1)
				{
					showLink(find);
				}
				else 
				{
					showLinkByRow(find);
				}
				printf("==========================================\n");
			}
			else 
			{
				printf("系统中没有找到此教师\n");
			}
			printf("--------按任意键回到菜单---------\n");
			getch();
			searchNodeByNameOrIdOrAll();
			break;
		case '3':
			showLinkByRowOrCol(pHead);
			printf("--------按任意键回到菜单---------\n");
			getch();
			searchNodeByNameOrIdOrAll();
			break;
		case '4':
			showLinkByRowOrCol(sortList(copyLink(pHead)));
			printf("--------按任意键回到菜单---------\n");
			getch();
			searchNodeByNameOrIdOrAll();
			break;
		case '5':
			menu();
			break;
		case '6':
			exit(0);
			break;
		}
	} while (ch != '0');
}